:root {
    --primary-green: #4CAF50;
    --light-green: #E8F5E9;
    --dark-green: #2E7D32;
    --gray: #f0f0f0;
    --dark-gray: #333;
    --white: #ffffff;

    /* 新增蓝色变量 */
    --primary-blue: #1565c0;
    --light-blue: #e3f2fd;
    --dark-blue: #0d47a1;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-gray);
    background-color: var(--light-green);
}

/* Custom styles for SweetAlert2 pop-ups */
.swal2-popup {
    background: var(--white);
}

.swal2-title,
.swal2-content {
    color: var(--dark-gray);
}

.swal2-actions .swal2-confirm {
    background-color: var(--primary-green) !important;
    color: var(--white) !important;
}

.swal2-actions .swal2-cancel {
    background-color: var(--gray) !important;
    color: var(--dark-gray) !important;
}

.swal2-input {
    border: 1px solid var(--dark-gray);
    color: var(--dark-gray);
}

.swal2-actions .swal2-confirm:hover {
    background-color: var(--dark-green) !important;
}

.swal2-actions .swal2-cancel:hover {
    background-color: var(--light-green) !important;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 250px;
    background-color: var(--white);
    border-right: 1px solid var(--light-green);
    padding: 1rem;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    color: var(--dark-green);
}

.add-conversation-button {
    background-color: var(--primary-green);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.add-conversation-button:hover {
    background-color: var(--dark-green);
}

.history-list {
    list-style-type: none;
}

.history-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.3s ease, padding-left 0.3s ease;
    border-radius: 5px;
}

.history-list li:hover {
    background-color: #e8f5e9;
    padding-left: 20px;
}

.history-list li .active {
    font-weight: bold;
    color: var(--primary-green);
}

.rename-button,
.delete-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.rename-button:hover,
.delete-button:hover {
    opacity: 1;
}

/* Source Document Link Styles */
.source-document {
    margin-top: 5px;
}

.source-document a {
    color: #21a0e4;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
}

/* Modal Styles for Document Content */
.modal .modal-content-document {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 8px;
    width: 50%;
    max-width: 80%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-content-document h3 {
    font-size: 30px;
}

.modal-content-document pre {
    margin-top: 30px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 18px;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 16px;
}

/* Chat Container Styles */
.chat-container {
    flex: 6;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--primary-green);
    color: var(--white);
}

.chat-header h2 {
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.user-info-name {
    font-weight: bold;
}

/* Custom Table Styles */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.custom-table thead {
    background-color: #388e3c;
    color: #fff;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
}

.custom-table th,
.custom-table td {
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

.custom-table tbody tr {
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.custom-table tbody tr:hover {
    background-color: #f1f1f1;
    transform: scale(1.02);
}

.custom-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.custom-table tbody td:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.custom-table tbody td:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

/* Menu Styles */
.menu {
    position: absolute;
    top: 60px;
    right: 1rem;
    background-color: var(--white);
    border: 1px solid var(--gray);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.menu ul {
    list-style-type: none;
}

.menu li {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.menu ul li a {
    color: inherit;
    text-decoration: none;
}

.menu li:hover {
    background-color: var(--light-green);
}

/* Chat Messages Styles */
.chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    background-color: #f9f9f9;
}

.chart-message {
    width: 100%;
    max-width: 100%;
}

.chart-message .message-content {
    max-width: 100%;
    width: 100%;
    text-align: center;
    display: block;
    padding: 0;
    margin: 0;
}

.chart-container {
    width: 100%;
    height: 400px;
    margin-top: 10px;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Message Bubble Styles */
.message {
    margin-bottom: 20px;
    display: flex;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}
/* Markdown 标题样式 */
.chat-messages h1,
.chat-messages h2,
.chat-messages h3,
.chat-messages h4,
.chat-messages h5,
.chat-messages h6 {
    color: var(--dark-blue);
    /* 使用深蓝色 */
    margin-bottom: 10px;
}

/* Markdown 列表样式 */
.chat-messages ul,
.chat-messages ol {
    margin-left: 20px;
    margin-bottom: 10px;
    color: var(--primary-blue);
    /* 保持文本颜色一致 */
}

/* Markdown 加粗文本样式 */
.chat-messages strong {
    color: var(--primary-blue);
    /* 加粗文本使用主蓝色 */
}

/* Markdown 代码块样式 */
.chat-messages pre {
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    color: var(--primary-blue);
    /* 代码块文本颜色 */
}

/* 链接样式 */
.chat-messages a {
    color: var(--primary-blue);
    text-decoration: underline;
}
/* Bot 消息样式 */
.bot-message .message-content {
    background-color: var(--light-blue);
    /* 使用淡蓝色背景 */
    color: var(--primary-blue);
    /* 使用主蓝色文字 */
    border-top-left-radius: 0;
}
.message-content {
    max-width: 90%;
    padding: 15px 20px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-message .message-content {
    background-color: #e8f5e9;
    color: var(--dark-green);
    border-top-right-radius: 0;
}

.bot-message .message-content {
    background-color: #e3f2fd;
    color: #1565c0;
    border-top-left-radius: 0;
}

/* Chat Input Styles */
.chat-input {
    display: flex;
    padding: 2rem;
    background-color: var(--white);
    border-top: 1px solid var(--gray);
}

.chat-input input {
    flex-grow: 1;
    padding: 1.5rem;
    border: 1px solid var(--gray);
    border-radius: 4px;
    margin-right: 0.5rem;
    font-size: 18px;
}

.chat-input button {
    background-color: var(--primary-green);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chat-input button:hover {
    background-color: var(--dark-green);
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
}

.close {
    color: var(--dark-gray);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--primary-green);
}

.h3-sql {
    margin-bottom: 1rem;
    color: var(--dark-green);
}

.label-sql {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--dark-green);
}

.text-sql {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--gray);
    border-radius: 4px;
    margin-bottom: 1rem;
}

.button-sql,
.button-sql-login {
    background-color: var(--primary-green);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-right: 0.5rem;
    margin-bottom: 1rem;
}

.button-sql:hover,
.button-sql-login:hover {
    background-color: var(--dark-green);
}

.table-sql {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table-sql th,
.table-sql td {
    border: 1px solid var(--gray);
    padding: 0.5rem;
    text-align: left;
}

.table-sql th {
    background-color: var(--light-green);
    color: var(--dark-green);
}
/* 加载动画容器 */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

/* 动态省略号 */
.ellipsis {
    display: inline-block;
    position: relative;
    width: 50px;
    height: 10px;
}

.ellipsis div {
    position: absolute;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dark-gray);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.ellipsis div:nth-child(1) {
    left: 0;
    animation: ellipsis1 0.6s infinite;
}

.ellipsis div:nth-child(2) {
    left: 16px;
    animation: ellipsis2 0.6s infinite;
}

.ellipsis div:nth-child(3) {
    left: 32px;
    animation: ellipsis3 0.6s infinite;
}
/* 添加到 styles.css */
.pulse-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
}

.pulse-loader div {
    width: 12px;
    height: 12px;
    background-color: #3498db;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}

.pulse-loader div:nth-child(1) {
    animation-delay: -0.32s;
}

.pulse-loader div:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes pulse {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}
@keyframes ellipsis1 {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes ellipsis2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(16px, 0) scale(0);
    }
}

@keyframes ellipsis3 {
    0% {
        transform: translate(32px, 0) scale(0);
    }

    100% {
        transform: translate(32px, 0) scale(1);
    }
}

/* 替换原来的 .spinner 样式 */
.spinner {
    display: none;
    /* 隐藏原来的 spinner */
}
/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        flex: none;
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .chat-container {
        height: calc(100vh - 200px);
    }

    .message {
        max-width: 90%;
    }
}